function checkDataFormat() {
    var userName = $("#userName").val(),
        nickname = $("#nickname").val(),
        majorName = $("#majorName").val(),
        requestAdress = $("#linkAdress").val(),
        requestType = $("#requestType").val(),
        dataType = $("#dataType").val(),
        dataContent = $("#dataContent").val();
    if (majorName == "undefined" || majorName == null || majorName == "") {
        $('#backMessage').val("用户名不能为空！");
        $("#backMessage").css({'display': 'block'});
        return false;
    }

    if (requestAdress == "undefined" || requestAdress == null || requestAdress == "") {
        $('#backMessage').val("请求地址不能为空！");
        $("#backMessage").css({'display': 'block'});
        return false;
    }

    if (requestType == "undefined" || requestType == null || requestType == "") {
        $('#backMessage').val("请求方式不能为空！");
        $("#backMessage").css({'display': 'block'});
        return false;
    }

    if (dataType == "undefined" || dataType == null || dataType == "") {
        $('#backMessage').val("数据类型不能为空！");
        $("#backMessage").css({'display': 'block'});
        return false;
    }
    if (dataContent == "undefined" || dataContent == null || dataContent == "") {
        $('#backMessage').val("数据内容不能为空!");
        $("#backMessage").css({'display': 'block'});
        return false;
    }


    var rootPath = getRootPath();
    var data = {
        name: nickname,
        creator: userName,
        major: majorName,
        reqAddr: requestAdress,
        reqMethod: requestType,
        dataType: dataType,
        data: dataContent
    };
    var linkInfo = '<a href="" id="simulator_link" target="_blank" >open the mock link ?</a>';
    $.ajax({
        url: "checkDataFormat",
        type: "post",
        data: JSON.stringify(data),
        dataType: "json",
        cache: false,
        async: false,
        contentType: "application/json;charset=utf-8",
        beforeSend: function (xhr) {
            xhr.setRequestHeader("version", "v2.0")
            console.log(this);
            // 禁用按钮防止重复提交
            $("#queryDataFormat").attr({disabled: "disabled"});
            $("#mock_link").empty();
        },
        success: function (msg) {
            if (msg.code == 0) {
                $('#mock_link').html(linkInfo);
                $('#backMessage').val(msg.data.callbackReport);
                $('#mock_link a').attr({href: "http://" + msg.data.simulatorUrl});
            } else {
                $('#backMessage').val(msg.message);
            }
            if (msg.message||msg.data.callbackReport)
                $("#backMessage").css({'display': 'block'});
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest);
            alert("状态码：" + textStatus + "失败:" + errorThrown);
        },
        complete: function (XMLHttpRequest, textStatus) {
            $('#queryDataFormat').removeAttr("disabled");
            if (textStatus == 'timeout') {
                var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
                xmlhttp.abort();
                $("#backMessage").html("网络超时！");
            }
        }
    });
}

/**
 * 获取根路径
 * @returns
 */
function getRootPath() {
    var strFullPath = window.document.location.href;
    var strPath = window.document.location.pathname;
    var pos = strFullPath.indexOf(strPath);
    var prePath = strFullPath.substring(0, pos);
    var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1) + "/";
    return (prePath + postPath);
}